package inc.zhugastrov.sellerform;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.eclipse.persistence.annotations.Direction;
import org.eclipse.persistence.annotations.NamedStoredProcedureQuery;
import org.eclipse.persistence.annotations.StoredProcedureParameter;

@Entity
@Table(name = "Item")
@NamedStoredProcedureQuery(name = "getItems", resultClass = Item.class, procedureName = "GetItems", parameters = {
		@StoredProcedureParameter(name = "id", queryParameter = "id", direction = Direction.OUT),
		@StoredProcedureParameter(name = "name", queryParameter = "name", direction = Direction.OUT),
		@StoredProcedureParameter(name = "brand", queryParameter = "brand", direction = Direction.OUT),
		@StoredProcedureParameter(name = "about", queryParameter = "about", direction = Direction.OUT),
		@StoredProcedureParameter(name = "price", queryParameter = "price", direction = Direction.OUT),
		@StoredProcedureParameter(name = "amountInStore", queryParameter = "amountInStore", direction = Direction.OUT)})
public class Item implements Product {
	@Id
	private Long id;
	@Column(nullable = false)
	private String name;
	private String brand;
	private String about;
	private Double price;
	@Column(name = "AMOUNT")
	private int amountInStore;

	@Override
	protected Object clone() throws CloneNotSupportedException {
		return super.clone();
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getBrand() {
		return brand;
	}

	public void setBrand(String brand) {
		this.brand = brand;
	}

	public String getAbout() {
		return about;
	}

	public void setAbout(String about) {
		this.about = about;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	public int getAmountInStore() {
		return amountInStore;
	}

	public void setAmountInStore(int amountInStore) {
		this.amountInStore = amountInStore;
	}

	public Item() {
		// TODO Auto-generated constructor stub
	}

	public Item(Basket basket) {
		setName(basket.getName());
		setBrand(basket.getBrand());
		setAbout(basket.getAbout());
		setPrice(basket.getPrice());
		setAmountInStore(basket.getAmountInStore());
		setId(basket.getId());
	}

	public Item(OrderedItems orderedItems) {
		setName(orderedItems.getName());
		setBrand(orderedItems.getBrand());
		setAbout(orderedItems.getAbout());
		setPrice(orderedItems.getPrice());
		setAmountInStore(orderedItems.getAmountInStore());
		setId(orderedItems.getId());
	}

	public Item(Long id) {
		setId(id);
		setName("New" + id);
		setBrand(id + "New");
		setAbout("Nothing");
		setPrice(1.1d);
		setAmountInStore(1);

	}

	@Override
	@Transient
	public void setWherehousePrice(Double price) {
		// TODO Auto-generated method stub
		
	}

	@Override
	@Transient
	public Double getWherehousePrice() {
		// TODO Auto-generated method stub
		return null;
	}

}
